package com.xayq.orap.oauth;

import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

import org.apache.oltu.oauth2.as.request.OAuthTokenRequest;
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;

import javax.servlet.http.HttpServletRequest;


public class MyOAuthTokenRequest extends OAuthTokenRequest {


    public MyOAuthTokenRequest(HttpServletRequest request) throws OAuthSystemException, OAuthProblemException {
        super(request);
    }

    public HttpServletRequest request() {
        return this.request;
    }
    
    public Set<String> getScopes() {
		String s = getParam("scope");
		Set scopes = new HashSet();
		if (!((s == null) || (s.trim().equals("")))) {
			StringTokenizer tokenizer = new StringTokenizer(s, ";");
			while (tokenizer.hasMoreElements()) {
				scopes.add(tokenizer.nextToken());
			}
		}
		return scopes;
	}
}
